#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <vector>
using namespace std;

class Solution
{
public:
    int pivotIndex(vector<int>& nums)
    {
        int n = nums.size();
        vector<int> f(n), g(n);
        for (int i = 1; i < n; i++)
            f[i] = f[i - 1] + nums[i - 1];
        for (int i = n - 2; i >= 0; i--)
            g[i] = g[i + 1] + nums[i + 1];
        for (int i = 0; i < n; i++)
        {
            if (f[i] == g[i]) return i;
        }
        return -1;
    }
};

int main()
{
    vector<int> nums;
    Solution sol;
    nums.push_back(1);
    nums.push_back(7);
    nums.push_back(3);
    nums.push_back(6);
    nums.push_back(5);
    nums.push_back(6);
    int ret = sol.pivotIndex(nums);
    cout << ret << endl;
    return 0;
}